/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:${USER}
 * Date:${YEAR}-${MONTH}-${DAY}
 * ${TIME}
 */
public class Main {
    public static void main(String[] args) {

        System.out.println("Hello world!");
    }
}
class Solution {
    public int longestOnes(int[] nums, int k) {
        int left=0,right=0,n=nums.length;
        int len=0;
        int zero=0;
        for(;right<n;right++){
            if(nums[right]==0){//进窗口
                zero++;
            }
            while(zero>k){//出窗口
                if(nums[left]==0){
                    zero--;
                }
                left++;
            }
            len=Math.max(len,right-left+1);//更新结果
        }
        return len;
    }
}